/*
 * Properties meta data of form components
 */

/*
 * ***********************************************************
 * DEFINE COPONENTS HERE
 * ***********************************************************
*/

/**
 * control - available components
 * 这里初始化所有显示组件属性需要的通用配置和基础配置
 */
function fpf_initComponentMeta() {
	
	//prop vars
	fmdc = {};
	fmdc.isEditor = true;
	fmdc.advancedview = false;
	fmdc.imagepath = flvar.imagepath;
	
	//component i18n
	fmd_i18n_modules = {};
    fmd_i18n_modules.typefilter = {
    	'01' : ['palleteico-task-service']
	};
	
	//all containers wrapper
	fldmeta_prop = {};

	//properties grid configuration
	//属性栏是使用dhtmlx表格控件，这里是表格的默认初始化属性
	fldmeta_prop.gridconf = {};
	fldmeta_prop.gridconf.isTreeGrid = true;//是否使用TreeGrid控件
    fldmeta_prop.gridconf.treeImagePath = resloc + "/static/skins/"+dhx_theme+"/assets/dhtmlx4/skins/"+dhx_skin+"_"+dhx_theme+"/imgs/";
    fldmeta_prop.gridconf.extIconPath = resloc + "/static/skins/"+dhx_theme+"/images/platform/designer/prop/";	//icon path
	fldmeta_prop.gridconf.header = [fmd_i18n_prop_prop,fmd_i18n_prop_value];
	////fldmeta_prop.gridconf.subHeader;
	fldmeta_prop.gridconf.colType="tree,ro";
	fldmeta_prop.gridconf.colIds="prop,value";
	fldmeta_prop.gridconf.colAlign="left,left";
	////fldmeta_prop.gridconf.colVAlign;
	fldmeta_prop.gridconf.colSorting="na,na";
	////fldmeta_prop.gridconf.colMinWidth;
	fldmeta_prop.gridconf.colInitWidth="190,*";
	fldmeta_prop.gridconf.colColor="#F8F8F8,white";
	////fldmeta_prop.gridconf.resize;
	fldmeta_prop.gridconf.visibile="false,false";
	fldmeta_prop.gridconf.enableTooltips="false,true";
	fldmeta_prop.gridconf.idx={};
	fldmeta_prop.gridconf.idx.prop=0;
	fldmeta_prop.gridconf.idx.value=1;
	fldmeta_prop.gridconf.tiprowbgcolor = "#e6f8fe";

	fldmeta_prop.func = {};	//common functions for component properties settings
	fldmeta_prop.funcOnCompAdded = {};	//common functions for component added
	fldmeta_prop.funcOnCompRemoved = {};	//common functions for component removed
	fldmeta_prop.funcOnCompChanged = {};	//common functions for component changed
	fldmeta_prop.funcOnCompResized = {};	//common functions for component resized
	fldmeta_prop.funcOnCompSelected = {};	//common functions for component selected
	fldmeta_prop.common = {};	//common properties settings for components
	fldmeta_prop.common.predefined = {};	//common properties that can be reused
	//fldmeta_prop.common.all = {};	//common properties settings for all components
	//fldmeta_prop.common.layout = {};	//common properties settings for all layout components
	//fldmeta_prop.common.activity = {};	//common properties settings for all datacontrol components
	//fldmeta_prop.common.event = {};	//common properties settings for event components
	//fldmeta_prop.common.gateway = {};	//common properties settings for gateway components
	fldmeta_prop.control = {};	//properties settings for all control components
	
	//predefined events
	
	fldmeta_prop.propDhxGridPredefinedEvents = {
		//这里定义的方法，在每个组件属性的每个onCellChanged事件时都会调用
		"onCellChanged" : function(rId,cId,nv) {
			//alert((rId.indexOf('i18nname')!=-1)+"=="+rId+"=="+(!fmdc.grid_prop.cells(rId, fldmeta_prop.gridconf.idx.value).getValue()));
			//var newv = fmdc.grid_prop.cells(rId, fldmeta_prop.gridconf.idx.value).getValue();
			if (cId==fldmeta_prop.gridconf.idx.value) {
				/*if (rId=='valueValidation') {
					fpf_showConditionalSub(rId, newv, fldmeta_prop.common.activity.properties[rId]);
				}*/
			} else if (!fmdc.grid_prop.cells(rId, fldmeta_prop.gridconf.idx.value).getValue() && rId.indexOf('i18nname')!=-1) {
				if ('i18nname-zh'==rId) {
					fmdc.grid_prop.cells(rId, fldmeta_prop.gridconf.idx.value).setValue(fmd_i18n_untitled);
				}/* else {
					fmdc.grid_prop.cells(rId, fldmeta_prop.gridconf.idx.value).setValue("Untitled");
				}*/
			}
		},
		"onEditCell" : function(stage,rId,cInd,nv,ov){//这里定义的方法，在每个组件属性的每个onEditCell事件时都会调用
			/*console.debug("1onEditCell=======");
			console.debug("1     stage======="+stage);
			console.debug("1       rId======="+rId);
			console.debug("1      cInd======="+cInd);
			console.debug("1    nValue======="+nv);
			console.debug("1    oValue======="+ov);
			console.debug("1onEditCell======="+ this.cells(rId,cInd).getValue());*/
			if (stage==0) {
				
			} else if ('ch'==this.getCellExcellType(rId,cInd) && stage==1) {
				//处理checkbox类型的属性值被用户修改时
				nv = this.cells(rId,cInd).getValue();
				if (fl.curComp && fl.curComp.id && fl.curflow.bpmnConfig && fl.curflow.bpmnConfig[fl.curComp.id]
					&& !MyUtilJs.isEqual(fl.curflow.bpmnConfig[fl.curComp.id][rId], nv)) {
					fl.curflow.bpmnConfig[fl.curComp.id][rId] = nv;
					//console.debug("onEditCell ch excel changed. fl.unSavedChange changed.");
					fl.unSavedChange = true;
				}
			} else if (stage==2 && !MyUtilJs.isEqual(fl.curflow.bpmnConfig[fl.curComp.id][rId], nv)) {
				fl.curflow.bpmnConfig[fl.curComp.id][rId] = nv;
				//console.debug("onEditCell stage==2 changed. fl.unSavedChange changed.");
				fl.unSavedChange = true;
			}
			return true;
		}
	};

	//available validators
	fldmeta_prop.runtime_validators = [
					["NotEmpty", fmd_i18n_vld_notempty],
					["ValidAplhaNumeric", fmd_i18n_vld_alphanumeric],
					["ValidAplhaNumericUnderline", fmd_i18n_vld_alphanumericunderline],
					["ValidDate", fmd_i18n_vld_date + '(yyyy-MM-dd)'],
					["ValidDatetimeMM", fmd_i18n_vld_datetime + '(yyyy-MM-dd hh:mm)'],
					["ValidDatetimeSS", fmd_i18n_vld_datetime + '(yyyy-MM-dd hh:mm:ss)'],
					["ValidTime", fmd_i18n_vld_time + '(hh:mm:ss)'],
					["ValidTimeNoSS", fmd_i18n_vld_time + '(hh:mm)'],
					["ValidInteger", fmd_i18n_vld_integer],
					["ValidPositiveInteger", fmd_i18n_vld_positiveinteger],
					["ValidNegativeInteger", fmd_i18n_vld_negativeinteger],
					["ValidNumeric", fmd_i18n_vld_numeric],
					["ValidPositiveNumeric", fmd_i18n_vld_positivenumeric],
					["ValidNegativeNumeric", fmd_i18n_vld_negativenumeric],
					["ValidCurrency", fmd_i18n_vld_currency],
					["ValidEmail", fmd_i18n_vld_email],
					["ValidCnMobile", fmd_i18n_vld_cnmobile],
					["ValidCnPhone", fmd_i18n_vld_cnphone],
					["ValidIPv4", fmd_i18n_vld_ipv4]
	                      ];
	
	//validators' i18n names
	fldmeta_prop.runtime_validators_i18n = {"NotEmpty": fmd_i18n_vld_notempty,
					"NotEmptyObject": fmd_i18n_vld_notempty,	//为对象时
   					"ValidAplhaNumeric": fmd_i18n_vld_alphanumeric,
   					"ValidAplhaNumericUnderline": fmd_i18n_vld_alphanumericunderline,
   					"ValidDate": fmd_i18n_vld_date + '(yyyy-MM-dd)',
   					"ValidDatetimeMM": fmd_i18n_vld_datetime + '(yyyy-MM-dd hh:mm)',
   					"ValidDatetimeSS": fmd_i18n_vld_datetime + '(yyyy-MM-dd hh:mm:ss)',
   					"ValidTime": fmd_i18n_vld_time + '(hh:mm:ss)',
   					"ValidTimeNoSS": fmd_i18n_vld_time + '(hh:mm)',
   					"ValidInteger": fmd_i18n_vld_integer,
   					"ValidPositiveInteger": fmd_i18n_vld_positiveinteger,
   					"ValidNegativeInteger": fmd_i18n_vld_negativeinteger,
   					"ValidNumeric": fmd_i18n_vld_numeric,
   					"ValidPositiveNumeric": fmd_i18n_vld_positivenumeric,
   					"ValidNegativeNumeric": fmd_i18n_vld_negativenumeric,
   					"ValidCurrency": fmd_i18n_vld_currency,
   					"ValidEmail": fmd_i18n_vld_email,
   					"ValidCnMobile": fmd_i18n_vld_cnmobile,
   					"ValidCnPhone": fmd_i18n_vld_cnphone,
   					"ValidIPv4": fmd_i18n_vld_ipv4,
   					"ValidPercent": fmd_i18n_vld_percent};
	
	//组件的i18n类型名称
	fldmeta_prop.i18n_type_names = fmd_i18n_flc_typenames;
	
	/**
	 * list of available controls
	 */
	//==================== common ====================
	
	/**
	 * common functions
	 * 一些通用方法
	 */
	//取得组件名称（文字标签内容），标签在组件内部时
	fldmeta_prop.func.getCompInnerName = function(elemid){
		//return $("g[data-element-id='"+elemid+"'] .djs-visual text tspan").html();
		var tspans= $("g[data-element-id='"+elemid+"'] .djs-visual text tspan");
		var strs = "";
		for(var x = 0;x<tspans.length;x++){
			strs += tspans[x].innerHTML;
		}
		return strs;
	};
	//取得当前组件名称（文字标签内容），标签在组件内部时
	fldmeta_prop.func.getCurCompInnerName = function(){
		var rtn = fldmeta_prop.func.getCompInnerName(fl.curComp.id);
		fl.curflow.bpmnConfig[fl.curComp.id]["i18nname-zh"] = rtn;
		return rtn;
	};
	//取得当前组件名称（文字标签内容），标签在组件外部时
	fldmeta_prop.func.getCompOuterName = function(elemid){
		var tspans= $("g[data-element-id='"+elemid+"_label'] .djs-visual text tspan");
		var strs = "";
		for(var x = 0;x<tspans.length;x++){
			strs += tspans[x].innerHTML;
		}
		return strs;
	};
	//取得当前组件名称（文字标签内容），标签在组件外部时
	fldmeta_prop.func.getCurCompOuterName = function(){
		var rtn = fldmeta_prop.func.getCompOuterName(fl.curComp.id);
		fl.curflow.bpmnConfig[fl.curComp.id]["i18nname-zh"] = rtn;
		return rtn;
	};
	//取得组件类型名称
	fldmeta_prop.func.getCurCompTypeName = function(){
		return fldmeta_prop.i18n_type_names[fl.curComp.type];
	};
	//取得组件类型名称
	fldmeta_prop.func.getCurCompTypeName = function(){
		return fldmeta_prop.i18n_type_names[fl.curComp.type];
	};
	
	//cell change event for common
	//各个组件的值发生改变时需要引用此方法，用来显示隐藏属性的子属性
	fldmeta_prop.func.onCellChanged_common = function(rId,cId,nv,confs) {
		if (!fl.curComp) return;
		if (nv && cId==fldmeta_prop.gridconf.idx.value && confs && confs[0] && confs[0]["conditional-sub"]) {
			fpf_showConditionalSub(rId, nv, confs[0]);
		}
	};
	
	//change current component styles
	fldmeta_prop.func.changeCurCompStyles = function(isCustom) {
		var styles = fldmeta_prop.control[fl.curComp.type].styles.displayStyle["conditional-sub"].custom;
		for (var s in styles) {
			//获取实时值
			var rv = fl.curflow.bpmnConfig[fl.curComp.id][s];
			//获取默认值
			var p = styles[s];
			var dv = typeof(p)=='function' ? p().value : p.value;
			dv = typeof(dv)=='function' ? dv() : dv["default"];
			if ( isCustom ) {
				//自定义风格并且实时值不等于默认值，使用实时值重置
				rv!=dv && fldmeta_prop.func[fl.curComp.type].onDisplayStyle(fl.curComp.id, s, rv);
			} else {
				//非自定义风格并且实时值不等于默认值，使用默认值重置
				rv!=dv && fldmeta_prop.func[fl.curComp.type].onDisplayStyle(fl.curComp.id, s, dv);
			}
		}
	};
	
	//change current component styles
	fldmeta_prop.func.onCellChanged_stylecommon = function(rId,cId,nv) {
		if (!fl.curComp) return;
		if (rId=="displayStyle" && nv!=fl.curflow.bpmnConfig[fl.curComp.id]["displayStyle"]) {
			fldmeta_prop.func.changeCurCompStyles("custom"==nv);
		} else if (rId.startsWith("displayStyle_")) {
			if ("custom"!=fl.curflow.bpmnConfig[fl.curComp.id]["displayStyle"]) {
				//获取默认值
				var p = fldmeta_prop.control[fl.curComp.type].styles.displayStyle["conditional-sub"].custom[rId];
				nv = typeof(p)=='function' ? p().value : p.value;
				nv = typeof(nv)=='function' ? nv() : nv["default"];//默认值
			}
			fldmeta_prop.func[fl.curComp.type].onDisplayStyle(fl.curComp.id, rId, nv);
		}
	};

    //取得事件类型
    fldmeta_prop.func.getEventDefinition = function(elem) {
        if (elem.businessObject.eventDefinitions && elem.businessObject.eventDefinitions[0]) {
            var et = elem.businessObject.eventDefinitions[0]['$type'];
            if (et.startsWith('bpmn:')) {
                et = et.substr(5);
                return et;
            }
        }
    }
    fldmeta_prop.func.getEventDefinitionById = function(elemid) {
        var elem = getIORegistedElem(elemid);
        return fldmeta_prop.func.getEventDefinition(elem);
    }

	//任务提醒属性的值发生改变时事件需要引用此方法
	fldmeta_prop.func.onCellChanged_remind = function(rId,cId,nv) {
		if (nv && cId==fldmeta_prop.gridconf.idx.value) {
			if (rId=='remind') {
				fpf_showConditionalSub(rId, nv, fldmeta_prop.common.predefined["remind"]);
			} else if (rId=='manualRemind') {
				fpf_showConditionalSub(rId, nv, fldmeta_prop.common.predefined["manualRemind"]);
			}
		}
	};
	
	//get outgoing transitions 获取输出路径
	fldmeta_prop.func.getOutgoingTransitions = function(elemid) {
		return fl_getOutgoingTransitions(elemid);
	};
	
	//check if abandon route property
	//判断当前环节是否需要有路由设置属性，如果没有则相应的去掉这些属性
	fldmeta_prop.func.getAbandonPropertiesForConditional = function() {
		var seqflows = fldmeta_prop.func.getOutgoingTransitions(fl.curComp.id);
		/*bi.saveDiagram(function(err, xml){
			var params = {
					"xmlStr" : xml,
					"xpath" : "//bpmn2:sequenceFlow[@sourceRef='"+fl.curComp.id+"']|//bpmn2:messageFlow[@sourceRef='"+fl.curComp.id+"']",
					"attrlist" : JSON.stringify(["id","name","targetRef"])
				};
			seqflows = doPostSyncJson(flvar.bpmeRest + "/"+flvar.flowRes+"/getElementAttrs", params);
		});*/
		if (seqflows && seqflows.length>1) {
			if (fl.curComp.type.indexOf('Task')>=0 && fl.curComp.type.indexOf('UserTask')<0) {
				return ["tiprow_activitycommon", "route"];
			}
			return null;
		} else {
			if (fl.curComp.type.indexOf('Gateway')>=0) {
				return ["tiprow_activitycommon", "route"];
			} else {
				return ["tiprow_activitycommon", "route"];
			}
		}
	};
	
	//检查流程变量是否存在
	fldmeta_prop.func.isValidProcessVar = function(pv) {
		return !MyUtilJs.isEmpty(fl.curflow.bpmnConfig.processSettings.variables[pv]);
	};
	
	//set route settings
	fldmeta_prop.func.setRoute = function(rId, cId) {
		var seqflows = null;
		var grids = {};
		var tbs = {};
		var suffix = flvar.isEditor ? ".gif" : "_dis.gif";
		//get outgoing sequence and message flows
		if (fl.curComp.type && (fl.curComp.type.indexOf("Task")>=0
				 || 'ExclusiveGateway'==fl.curComp.type
				 || 'InclusiveGateway'==fl.curComp.type)) {
			seqflows = fldmeta_prop.func.getOutgoingTransitions(fl.curComp.id);
			/*bi.saveDiagram(function(err, xml){
				var params = {
						"xmlStr" : xml,
						"xpath" : "//bpmn2:sequenceFlow[@sourceRef='"+fl.curComp.id+"']|//bpmn2:messageFlow[@sourceRef='"+fl.curComp.id+"']",
						"attrlist" : JSON.stringify(["id","name","targetRef"])
					};
				seqflows = doPostSyncJson(flvar.bpmeRest + "/"+flvar.flowRes+"/getElementAttrs", params);
			});*/
		}/* else if ('SequenceFlow'==fl.curComp.type) {
			bi.saveDiagram(function(err, xml){
				var params = {
						"xmlStr" : xml,
						"cmds" : JSON.stringify([{
							"xpath" : "//bpmn2:sequenceFlow[@id='"+fl.curComp.id+"']",
							"attrlist" : ["sourceRef"]
						}]) 
					};
				doPostSyncJson(flvar.bpmeRest + "/"+flvar.flowRes+"/getElementAttrsByCmdChain", params);
				seqflows = [fl.curComp.id];
			});
		} else if ('MessageFlow'==fl.curComp.type) {
			bi.saveDiagram(function(err, xml){
				var params = {
						"xmlStr" : xml,
						"cmds" : JSON.stringify([{
							"xpath" : "//bpmn2:messageFlow[@id='"+fl.curComp.id+"']",
							"attrlist" : ["sourceRef"]
						}])
					};
				doPostSyncJson(flvar.bpmeRest + "/"+flvar.flowRes+"/getElementAttrsByCmdChain", params);
				seqflows = [fl.curComp.id];
			});
		}*/
		if (!seqflows || !seqflows.length) {
			msg(fmd_i18n_msg_nooutgoing);
			return;
		}
		/*if (!fl.curflow.bpmnConfig.processSettings.variables || MyUtilJs.isEmpty(fl.curflow.bpmnConfig.processSettings.variables)) {
			msg(fmd_i18n_msg_plsConfigPv);
			return;
		}*/
		
		//init window
		var w1 = fm_createCenterWindow('wid_route', fmd_i18n_prop_route, 800, 600);
		var lo1 = w1.attachLayout("2E");
		lo1.cells('a').hideHeader();
		lo1.cells('b').hideHeader();
		lo1.cells('b').setHeight(50);
		
		//init toolbar
		/*var rtb1 = lo1.cells('a').attachToolbar();
		rtb1.setIconsPath(flvar.imagepath);
		rtb1.addButtonTwoState('btn_allowSelPath', 0, fmd_i18n_prop_allowSelPath, "item_chk0"+suffix, "item_chk0"+suffix);
		rtb1.attachEvent("onStateChange", function(id, state){
			if (id=='btn_allowSelPath') {
				if (state) {
					rtb1.setItemImage('btn_allowSelPath', "item_chk1"+suffix);
				} else {
					rtb1.setItemImage('btn_allowSelPath', "item_chk0"+suffix);
				}
			}
		});*/
		
		//init accordions
		var acc1 = lo1.cells('a').attachAccordion();
		//$(acc1.base).css("margin-top", "3px");
		
		//process variable object list
		var pvobjs = {"_approvalResult" : {allowin: "0",
					allowout: "0",
					desc: fmd_i18n_prop_approvalResult,
					type: "boolean"}};
		$.extend(pvobjs, fl.curflow.bpmnConfig.processSettings.variables);
		//process variable list
		var pvlist1 = [];
		for (var v in pvobjs) {
			pvlist1.push([v, v]);
		}
		
		
		var count = 1;	//路由条件的行计数器,生成rowId
		
		//隐藏显示按钮和grid
		//acid为路径id，state为该路径是否是默认路径
		//如果是默认路径，则不需要配置条件的表格，否则显示
		function toggleButtonsAndGrid(acid, state) {
			if (state) {
				tbs[acid].setItemImage('btn_default', "item_chk1"+suffix);
				tbs[acid].hideItem('btn_add');
				tbs[acid].hideItem('btn_del');
				//tbs[acid].hideItem('btn_up');
				//tbs[acid].hideItem('btn_down');
				$(acc1.cells(acid).cell).find('div.dhx_cell_cont_acc').hide();
			} else {
				tbs[acid].setItemImage('btn_default', "item_chk0"+suffix);
				tbs[acid].showItem('btn_add');
				tbs[acid].showItem('btn_del');
				//tbs[acid].showItem('btn_up');
				//tbs[acid].showItem('btn_down');
				$(acc1.cells(acid).cell).find('div.dhx_cell_cont_acc').show();
			}
		}
		
		//init accordion cell
		//在手风琴控件中，为每一个目标路径初始化一个配置面板
		//acid是路径的id，idx为路径编号，从1开始
		function initAccordionCell(acid, idx) {
			acc1.addItem(acid, fmd_i18n_prop_connection + " "+(idx+1)+" "+
					"("+seqflows[idx].id + ") "+
					fmd_i18n_prop_connectionname+ ": " + (seqflows[idx].name||fmd_i18n_prop_connectionunnamed) + "   "+
					//"<img src='"+fmdc.grid_prop.extIconPath+"in.png' valign='absmiddle'/>" + 
					fmd_i18n_prop_connectiontarget + ": " + 
					(getIORegistedElem(seqflows[idx].targetRef).name|| $("svg g[data-element-id='"+seqflows[idx].targetRef+"'] tspan").html() ||fmd_i18n_prop_connectionunnamed));
			var ragrid = acc1.cells(acid).attachGrid();
			ragrid.setIconsPath(flvar.imagepath);
			ragrid.setHeader([fmd_i18n_prop_processvars,
			                  fmd_i18n_prop_description,
			                  fmd_i18n_prop_type,
			                  fmd_i18n_prop_connection_rel,
			                    fmd_i18n_prop_value,
			                    fmd_i18n_prop_type],
			                    null,
			                    ["text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;"]);
			ragrid.setInitWidths("150,150,90,90,*,80");
			ragrid.setColumnIds("VARNAME,VARDESC,TYPEDESC,OP,VALUE,TYPE");
			ragrid.setColTypes("ro,ro,ro,ro,ro,ro");
			ragrid.setColSorting("na,na,na,na,na,na");
			ragrid.setColumnsVisibility("false,false,false,false,false,true");
			ragrid.setColAlign("left,left,center,center,left,left");
			ragrid.setEditable(fmdc.grid_prop.isEditor);
			ragrid.setLang(flvar.lang);
			ragrid.enableValidation(true,true);
			ragrid.setDateFormat("%Y-%m-%d");
			ragrid.enableEditEvents(fmdc.grid_prop.isEditor, false, false);
			ragrid.init();
			grids[acid] = ragrid;
			
			//当变量名称发生改变时，相应的操作符列的类型和值列的验证方式随之发生改变
			ragrid.attachEvent("onCellChanged", function(rid1,cid1,nv1){
				if (nv1 && nv1!='&nbsp;' && cid1==0) {
					var type1st;
					type1st = pvobjs[nv1].type;
					var oplist1 = null;
					var excelType1 = null;
					var vld1 = null;
					if (type1st=='string') {
						oplist1 = fmd_i18n_operatorlist_string;
						excelType1 = "edtxt";
						vld1 = 'NotEmpty';
					} else if (type1st=='boolean') {
						oplist1 = fmd_i18n_operatorlist_boolean;
						//excelType1 = "_approvalResult"==nv1 ? {"type":"coro","options":fmd_i18n_valuelist_approvals} : {"type":"coro","options":fmd_i18n_valuelist_boolean};
						excelType1 = {"type":"coro","options":fmd_i18n_valuelist_boolean};
					} else if (type1st=='int') {
						oplist1 = fmd_i18n_operatorlist_number;
						excelType1 = "edtxt";
						vld1 = 'ValidInteger';
					} else if (type1st=='number') {
						oplist1 = fmd_i18n_operatorlist_number;
						excelType1 = "edtxt";
						vld1 = 'ValidNumeric';
					} else if (type1st=='date') {
						oplist1 = fmd_i18n_operatorlist_date;
						excelType1 = "dhxCalendar";
						vld1 = 'ValidDate';
					} else if (type1st=='json') {
						oplist1 = fmd_i18n_operatorlist_json;
						excelType1 = "edtxt";
						vld1 = 'NotEmpty';
					}
					ragrid.grid_bindCombo(rid1, 3, 
							oplist1, 
							{"comboSize":10, "comboWidth":100}, 
							oplist1[0][0]);
					ragrid.cells(rid1,1).setValue(pvobjs[nv1].desc);
					ragrid.cells(rid1,2).setValue(fmd_i18n_prop_processvar_valsenum[type1st]);
					ragrid.cells(rid1,5).setValue(type1st);
					if (typeof(excelType1)=='object' && excelType1.type=='coro') {//boolean
						ragrid.setCellExcellType(rid1, 4,  excelType1.type);
						ragrid.grid_bindCombo(rid1, 4, 
								excelType1.options, 
								{"comboSize":10, "comboWidth":100}, 
								excelType1.options[0][0]);
					} else {
						ragrid.setCellExcellType(rid1, 4,  excelType1);
						ragrid.cells(rid1,4).setValue(null);
					}
					//设置验证
					ragrid.cells(rid1, 4).setAttribute("validate",vld1);
				}
			});
			
			//增加按钮栏
			var ratb = acc1.cells(acid).attachToolbar();
			ratb.setIconsPath(flvar.imagepath);
			ratb.addButtonTwoState('btn_default', 0, fmd_i18n_prop_connection_default, 'item_chk0.gif', 'item_chk0_dis.gif');
			ratb.addSpacer('btn_default');
			ratb.addButton('btn_add', 1, fmd_i18n_prop_connection_newcnd, 'new1.png', 'new1_dis.png');
			ratb.addButton('btn_del', 2, fmd_i18n_prop_connection_delcnd, 'delete1.png', 'delete1_dis.png');
			if (!fmdc.grid_prop.isEditor) {
				ratb.disableItem("btn_default");
				ratb.disableItem("btn_add");
				ratb.disableItem("btn_del");
			}
			
			//ratb.addButton('btn_up', 3, fmd_i18n_prop_connection_up, 'up1.bmp', 'up1_dis.bmp');
			//ratb.addButton('btn_down', 4, fmd_i18n_prop_connection_down, 'down1.bmp', 'down1_dis.bmp');
			tbs[acid] = ratb;
			//绑定按钮事件
			ratb.attachEvent("onClick", function(tid) {
				if (tid=='btn_add') {
					if (MyUtilJs.isEmpty(pvlist1)) {
						msg(fmd_i18n_msg_plsConfigPv);
						return;
					}
					var rid = count++;
					ragrid.addRow(rid, [null, null, null, null, null, null]);
					ragrid.grid_bindCombo(rid, 0, 
							pvlist1, 
							{"comboSize":10, "comboWidth":100}, 
							pvlist1[0][0]);
				} else if (tid=='btn_del') {
					var rn = ragrid.getSelectedRowId();
					if (!rn) {
						dhtmlx.message(fmd_i18n_prop_msg_plsselline);
					} else {
						ragrid.deleteRow(rn);
					}
				}
			});
			//当是否默认路径按钮值反生改变
			ratb.attachEvent("onStateChange", function(tid, state) {
				if (tid=='btn_default') {
					toggleButtonsAndGrid(acid, state);
					//set other accordion cell toolbar
					for (var i in tbs) {
						if (i!= acid && state) {
							tbs[i].setItemState(tid, false);
							toggleButtonsAndGrid(i, false);
						}
					}
				}
			});
		}
		
		//init accordion cells, grids and toolbars
		//循环为每个路径增加配置相关面板
		for (var i=0; i<seqflows.length; i++) {
			var acid = seqflows[i].id;
			initAccordionCell(acid, i);
			//load existing values
			//加载已有配置
			if (fl.curflow.bpmnConfig[fl.curComp.id].route) {
				//允许用户选择按钮
				/*rtb1.setItemState('btn_allowSelPath', !!fl.curflow.bpmnConfig[fl.curComp.id].route.allowSelectPath);
				if (!!fl.curflow.bpmnConfig[fl.curComp.id].route.allowSelectPath) {
					rtb1.setItemImage('btn_allowSelPath', "item_chk1"+suffix);
				} else {
					rtb1.setItemImage('btn_allowSelPath', "item_chk0"+suffix);
				}*/
				//是否默认
				if (fl.curflow.bpmnConfig[fl.curComp.id].route.defaultTransition && acid == fl.curflow.bpmnConfig[fl.curComp.id].route.defaultTransition) {
					tbs[acid].setItemState('btn_default', true);
					toggleButtonsAndGrid(acid, true);
					if (!fmdc.grid_prop.isEditor) {
						tbs[acid].hideItem("btn_default")
						tbs[acid].addText('lbl_default', 0, '<img style="vertical-align:middle" src="'+flvar.imagepath+"item_chk1"+suffix+'"/>'+fmd_i18n_prop_connection_default);
					}
				} else {
					if(!fl.curflow.bpmnConfig[fl.curComp.id].route || !fl.curflow.bpmnConfig[fl.curComp.id].route.transitionConditions) {
						continue;
					}
					var conds1 = fl.curflow.bpmnConfig[fl.curComp.id].route.transitionConditions[acid];
					if (conds1 && conds1.length) {
						for (var j=0;j<conds1.length;j++) {
							if (pvobjs[conds1[j].varname]) {
								var rid1 = count++;
								grids[acid].addRow(rid1, [null, null, null, null, null, null]);
								grids[acid].grid_bindCombo(rid1, 0, 
										pvlist1, 
										{"comboSize":10, "comboWidth":100}, 
										conds1[j].varname);
								grids[acid].cells(rid1,3).setValue(conds1[j].operator);
								grids[acid].cells(rid1,4).setValue(conds1[j].value);
							}
						}
					}
				}
			}
		}
		
		//init bottom form and button
		//增加底端按钮，绑定OK事件
		var str2 = [{ type:"block" , name:"form_block_1", offsetLeft:(dhx_skin=="dhx_web"?"332":"337"), offsetTop:"0", 
					list:[{ type:"button" , name:"fb_ok", value:fmd_i18n_b_ok, inputTop:0  }] }];
		var fm2 = lo1.cells('b').attachForm(str2);
		fm2.attachEvent("onButtonClick", function(btid) {
			if (!fmdc.grid_prop.isEditor) {
				w1.close();
			} else if (btid=='fb_ok') {
				//将配置信息存入fl.curflow.bpmnConfig
				var route = {};
				var transitionConditions = {};
				//get default transition
				//循环每个按钮栏和表格
				for (var acid in tbs) {
					if (tbs[acid].getItemState('btn_default')) {//是默认路径时
						route.defaultTransition = acid;
					} else {//不是默认路径时
						//collection grid conditions
						var rn = grids[acid].getRowsNum();
						//validate values
						if (rn) {
							var conds1 = [];
							//循环添加条件
							for (var i=0; i<rn;i++) {
								var rid1 = grids[acid].getRowId(i);
								var vid = grids[acid].cells(rid1,0).getValue();
								//验证条件值是否合法
								if(grids[acid].cells(rid1, 4).getAttribute("validate") && !grids[acid].validateCell(rid1, 4)) {
									msg(fmd_i18n_msg_plscorrect + ' : ' + vid);
									return;
								}
								conds1.push({
									"varname" : grids[acid].cells(rid1,0).getValue(),//引用的流程变量名称
									"type" : grids[acid].cells(rid1,5).getValue(),//类型
									"operator" : grids[acid].cells(rid1,3).getValue(),//操作符
									"vardesc" : grids[acid].cells(rid1,1).getValue(),//变量描述
									"value" : grids[acid].cells(rid1,4).getValue()//值
								});
							};
							if (!MyUtilJs.isEmpty(conds1)) {
								transitionConditions[acid] = conds1;
							}
						}
					}
				}
				if (!MyUtilJs.isEmpty(transitionConditions)) {
					route.transitionConditions = transitionConditions;
				}
				//route.allowSelectPath = rtb1.getItemState("btn_allowSelPath");
				fl.curflow.bpmnConfig[fl.curComp.id].route = route;
				fmdc.grid_prop.cells(rId, cId).setValue(route, true);
				w1.close();
			}
		});
	};
	
	//get activity vars
	//验证流程时使用，获取环节的变量配置信息，并调用回调方法callback
	fldmeta_prop.func.getActivityVarsAndCheckValWithCallback = function(elemid, val, callback) {
		var activityVars = null;
		var type1 = getBpmnType(getIORegistedElem(elemid));//获取bpmn类型
		if (type1=='SubProcess') {//如果是子流程，流程变量即变量，根据允许输入和允许输出得到输入输出变量
			var pvlist1 = fl.curflow.bpmnConfig[elemid]["processvars"];
			if (pvlist1 && !MyUtilJs.isEmpty(pvlist1)) {
				activityVars = {};
				activityVars.input = {}, activityVars.output = {};
				for (var pv1 in pvlist1) {
					if (pvlist1[pv1].allowin=='1' || pvlist1[pv1].allowin==1) {
						activityVars.input[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
					if (pvlist1[pv1].allowout=='1' || pvlist1[pv1].allowout==1) {
						activityVars.output[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
				}
			}
			if (!activityVars || (MyUtilJs.isEmpty(activityVars.input) && MyUtilJs.isEmpty(activityVars.output))) {
				//msg(fmd_i18n_msg_plsConfigSubPv);
			} else {
				callback(elemid, val, activityVars);
			}
		} else if (type1=='SubProcessCollapsed') {//链接子流程，流程变量即变量，根据允许输入和允许输出得到输入输出变量
			var pvlist1 = null;
			if (fl.curflow.bpmnConfig[elemid].processRef && fl.curflow.bpmnConfig[elemid].processRef.id) {
                var ret = doGetSyncJson(flvar.bpmeRest+"/bpdVersion/" + fl.curflow.bpmnConfig[elemid].processRef.id + "/"+(fl.curflow.bpmnConfig[elemid].processRef.versionid||'current')+'?timezoneOffset='+new Date().getTimezoneOffset());
				var bpmnConfig1 = ret.bpmnConfig;
				bpmnConfig1.processSettings && (pvlist1 = bpmnConfig1.processSettings.variables);
			} else {
				//msg(fmd_i18n_prop_msg_plsselprocessref);
			}
			
			if (pvlist1 && !MyUtilJs.isEmpty(pvlist1)) {
				activityVars = {};
				activityVars.input = {}, activityVars.output = {};
				for (var pv1 in pvlist1) {
					if (pvlist1[pv1].allowin=='1' || pvlist1[pv1].allowin==1) {
						activityVars.input[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
					if (pvlist1[pv1].allowout=='1' || pvlist1[pv1].allowout==1) {
						activityVars.output[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
				}
			}
			if (!activityVars || (MyUtilJs.isEmpty(activityVars.input) && MyUtilJs.isEmpty(activityVars.output))) {
				//msg(fmd_i18n_msg_plsConfigSubPv);
			} else {
				callback(elemid, val, activityVars);
			}
		} else if (type1=='UserTask') {//如果为人工任务，则需要调用接口读取相关配置
			//get activity vars from api
			if (!callback) {
				callback = function(elemid, val, ret) {
					if (!ret || (!ret.input && !ret.output)) {
						msg(fmd_i18n_msg_noPvOnActivity);
						return null;
					}
				};
			}
			var activityVars = fl.curflow.otherConfig.validationData[elemid]["bindedFormModels"];
			callback(elemid, val, activityVars);
		}
	};

	//set data mapping
	//调用设置数据映射
	fldmeta_prop.func.callSetDataMapping = function(rId, cId) {
		//检查流程变量
		if (!fl.curflow.bpmnConfig.processSettings.variables || MyUtilJs.isEmpty(fl.curflow.bpmnConfig.processSettings.variables)) {
			msg(fmd_i18n_msg_plsConfigPv);
			return;
		}
		
		var elemid = fl.curComp.id;
		var activityVars = null;
		var type1 = getBpmnType(getIORegistedElem(elemid));
		/*if (type1=='SubProcess') {//如果是子流程，流程变量即变量，根据允许输入和允许输出得到输入输出变量
			var pvlist1 = fl.curflow.bpmnConfig[elemid]["processvars"];
			if (pvlist1 && !MyUtilJs.isEmpty(pvlist1)) {
				activityVars = {};
				activityVars.input = {}, activityVars.output = {};
				for (var pv1 in pvlist1) {
					if (pvlist1[pv1].allowin=='1' || pvlist1[pv1].allowin==1) {
						activityVars.input[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
					if (pvlist1[pv1].allowout=='1' || pvlist1[pv1].allowout==1) {
						activityVars.output[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
				}
			}
			if (!activityVars || (MyUtilJs.isEmpty(activityVars.input) && MyUtilJs.isEmpty(activityVars.output))) {
				msg(fmd_i18n_msg_plsConfigSubPv);
				return null;
			} else {
				fldmeta_prop.func.setDataMapping(rId, cId, activityVars);
			}
		} else */if (type1=='SubProcessCollapsed') {//如果是链接子流程，流程变量即变量，根据允许输入和允许输出得到输入输出变量
			var pvlist1 = null;
			if (fl.curflow.bpmnConfig[elemid].processRef && fl.curflow.bpmnConfig[elemid].processRef.id) {
				var ret = doGetSyncJson(flvar.bpmeRest+"/bpdVersion/" + fl.curflow.bpmnConfig[elemid].processRef.id + "/"+(fl.curflow.bpmnConfig[elemid].processRef.versionid||'current')+'?timezoneOffset='+new Date().getTimezoneOffset());
				var bpmnConfig1 = ret.bpmnConfig;
				bpmnConfig1.processSettings && (pvlist1 = bpmnConfig1.processSettings.variables);
			} else {
				msg(fmd_i18n_prop_msg_plsselprocessref);
				return null;
			}
			
			if (pvlist1 && !MyUtilJs.isEmpty(pvlist1)) {
				activityVars = {};
				activityVars.input = {}, activityVars.output = {};
				for (var pv1 in pvlist1) {
					if (pvlist1[pv1].allowin=='1' || pvlist1[pv1].allowin==1) {
						activityVars.input[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
					if (pvlist1[pv1].allowout=='1' || pvlist1[pv1].allowout==1) {
						activityVars.output[pv1] = {"type":pvlist1[pv1].type, "desc":pvlist1[pv1].desc};
					}
				}
			}
			if (!activityVars || (MyUtilJs.isEmpty(activityVars.input) && MyUtilJs.isEmpty(activityVars.output))) {
				msg(fmd_i18n_msg_plsConfigSubPv);
				return null;
			} else {
				fldmeta_prop.func.setDataMapping(rId, cId, activityVars);
			}
		} else if (type1=='UserTask') {//如果为人工任务，则需要调用接口读取相关视图配置
			//get activity vars from api
			var form1 = fmdc.grid_prop.cells("formBinding", fldmeta_prop.gridconf.idx.value).getValue();
			//console.log(form1);
			if (!MyUtilJs.isEmpty(form1)) {
				doPostAsyncJson(flvar.fmdCtx+"/rest/fmd/getVersion", {"formid":form1.formid, "versionid":form1.versionid},
						function(ret){
							//console.log(ret);
							var r1 = fldmeta_prop.func.UserTask.parseModelToInputOutput(ret);
							//console.log(r1);
							if (!r1) {
								msg(fmd_i18n_msg_invalidmodelinform);
							} else if (MyUtilJs.isEmpty(r1)) {
                                msg(fmd_i18n_msg_nomainmodelinform);
                            } else if (r1.input && r1.output && MyUtilJs.isEmpty(r1.input) && MyUtilJs.isEmpty(r1.output)) {
                                msg(fmd_i18n_msg_noPvOnActivity);
                            } else {
								fldmeta_prop.func.setDataMapping(rId, cId, r1);
							}
						}
					);
			} else {
				msg(fmd_i18n_msg_plsselformver);
			}
		} else if (type1=='ServiceTask') {//如果为系统任务，则需要调用接口读取相关配置
			//get activity vars from api
			var svc = fmdc.grid_prop.cells("serviceRef", fldmeta_prop.gridconf.idx.value).getValue();
			console.log(svc);
			if (MyUtilJs.isEmpty(svc)) {
				msg(fmd_i18n_msg_plsselservice);
			} else {
				doGetAsyncJson(flvar.bpmeRest+"/service/"+svc.realValue+"?timezoneOffset="+new Date().getTimezoneOffset(),
						function(ret){
							console.log(ret);
							if (!ret) {
								msgErr(fmd_i18n_msg_readfail);
								return;
							}
							if (ret.svcConfig && ret.svcConfig.intfvars) {
								if (!ret.svcConfig.intfvars.input || !ret.svcConfig.intfvars.input.length) {
									msg(fmd_i18n_msg_invalidserviceinput);
									return;
								}
								if (!ret.svcConfig.intfvars.output || !ret.svcConfig.intfvars.output.length) {
									msg(fmd_i18n_msg_invalidserviceoutput);
									return;
								}
								var input = {"INPUT" : {"desc": fmd_i18n_elsvc_input, "children":{}} };
								for (var i in ret.svcConfig.intfvars.input) {
									input.INPUT.children[ret.svcConfig.intfvars.input[i].varname] = {"type":ret.svcConfig.intfvars.input[i].vartype,"desc":ret.svcConfig.intfvars.input[i].vardesc};
								}
								var output = {"OUTPUT" : {"desc": fmd_i18n_elsvc_output, "children":{}} };
								for (var i in ret.svcConfig.intfvars.output) {
									output.OUTPUT.children[ret.svcConfig.intfvars.output[i].varname] = {"type":ret.svcConfig.intfvars.output[i].vartype,"desc":ret.svcConfig.intfvars.output[i].vardesc};
								}
								var r1 = {"input":input, "output":output};
								console.log(r1);
								fldmeta_prop.func.setDataMapping(rId, cId, r1);
							}
						}
					);
			}
		}
	};

	//set data mapping
	//弹出数据映射配置窗口进行数据映射配置
	fldmeta_prop.func.setDataMapping = function(rId, cId, activityVars) {
		var tbs = {};	//toolbars
		var gdspv = {};	//grid of process vars
		var gdsav = {};	//grid of activity vars
		
		if (!activityVars) {
			return;
		}
		
		var w1 = fm_createCenterWindow('wid_dataMapping', fmd_i18n_title_dataMapping, 800, 600);
		var lo1 = w1.attachLayout("2E");
		lo1.cells('a').hideHeader();
		lo1.cells('b').hideHeader();
		lo1.cells('b').setHeight(50);
		
		//iterately get var path consolidated by var names splitted by |
		//组装变量路径，通过|链接所有父变量名称和变量名称
		function getVarPath(accid, vrid, varpath) {
			var prid = gdsav[accid].getParentId(vrid);
			if (prid==null || prid==0) {
				return varpath;
			} else {
				var pvar = gdsav[accid].cells(prid, 0).getValue();
				varpath = pvar + "|" + varpath;
				return getVarPath(accid, prid, varpath);
			}
		}
		
		//load existing activity input/output to grid
		//迭代循环加载变量配置到表格 rootId是父节点ID，从0开始迭代，avlist是变量列表，accid是（input或output），标识输入或输出
		function loadActivityVars(rootId, avlist, accid) {
			if (avlist) {
				var count = 1;
				for (id in avlist) {
					var rid = rootId+"_"+count++;
					gdsav[accid].addRow(rid, [id, avlist[id].type, avlist[id].desc], null, rootId);
					if (avlist[id].type) {
						gdsav[accid].grid_bindCombo(rid, 1, 
								fmd_i18n_prop_processvar_vals, 
								{"comboSize":10, "comboWidth":100}, 
								avlist[id].type);
						//set isParam
						gdsav[accid].setRowAttribute(rid, "isParam", true);
						gdsav[accid].cells(rid, 3).setValue("<img src='"+fmdc.grid_prop.extIconPath+"arrow-"+accid+".png'/>");
						//set existing value
						if (fl.curflow.bpmnConfig[fl.curComp.id].dataMapping && fl.curflow.bpmnConfig[fl.curComp.id].dataMapping[accid]) {
							var varpath = getVarPath(accid, rid, id);
							gdsav[accid].cells(rid, 4).setValue(fl.curflow.bpmnConfig[fl.curComp.id].dataMapping[accid][varpath]);
						}
						gdsav[accid].cells(rid, 0).setImage(fmdc.grid_prop.extIconPath+"param.png");
					} else if (avlist[id].children) {
						gdsav[accid].cells(rid, 0).setImage(fmdc.grid_prop.extIconPath+"module.png");
						loadActivityVars(rid, avlist[id].children, accid);
					}
				}
			}
		}
		
		//初始化 accordion cells
		//初始化手风琴控件，输入和输出各自占一个页签，页签内包含左右两个可以支持数据拖动的表格
		//表格分别包含环节变量和流程变量
		function initAccCell(acc1, accid) {
			acc1.addItem(accid, eval('fmd_i18n_title_dataMapping_'+accid));
			tbs[accid] = acc1.cells(accid).attachToolbar();
			tbs[accid].setIconsPath(flvar.imagepath);
			tbs[accid].addButton('btn_clear', 0, fmd_i18n_prop_clear, 'delete1.png', 'delete1_dis.png');
			tbs[accid].addButton('btn_clearAll', 1, fmd_i18n_prop_clearAll, 'delete1.png', 'delete1_dis.png');
			
			if (!fmdc.grid_prop.isEditor) {
				tbs[accid].disableItem('btn_clear');
				tbs[accid].disableItem('btn_clearAll');
			}
			
			var loacc1 = acc1.cells(accid).attachLayout("2U");
			loacc1.cells('a').setText(eval('fmd_i18n_title_dataMapping_param_'+accid));
			loacc1.cells('b').setText(fmd_i18n_prop_processvars);
			loacc1.cells('a').setWidth(500);
			
			//grid process vars
			gdspv[accid] = loacc1.cells('b').attachGrid();
			gdspv[accid].setHeader([fmd_i18n_prop_variablename,
			                  fmd_i18n_prop_type,
			                  fmd_i18n_prop_allowin,
			                  fmd_i18n_prop_allowout,
			                  	fmd_i18n_prop_desc],
			                    null,
			                    ["text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;"]);
			gdspv[accid].setInitWidths("80,60,60,60,*");
			gdspv[accid].setColumnIds("VARNAME,VARTYPE,ALLOWIN,ALLOWOUT,VARDESC");
			gdspv[accid].setColTypes("ro,coro,ch,ch,ro");
			gdspv[accid].setColSorting("str,str,int,int,na");
			gdspv[accid].setColAlign("left,left,center,center,left");
			gdspv[accid].setColumnsVisibility("false,false,true,true,false");
			gdspv[accid].setEditable(false);
			gdspv[accid].enableDragAndDrop(fmdc.grid_prop.isEditor);
			gdspv[accid].setLang(flvar.lang);
			gdspv[accid].enableAlterCss("","");
			gdspv[accid].init();
			
			//grid activity vars
			gdsav[accid] = loacc1.cells('a').attachGrid();
			gdsav[accid].setHeader([fmd_i18n_prop_variablename,
			                    fmd_i18n_prop_type,
			                    fmd_i18n_prop_desc,
			                    "",
			                    fmd_i18n_prop_mapping],
			                    null,
			                    ["text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;",
			                     "text-align:center;"]);
			fldmeta_prop.gridconf.treeIconPath && gdsav[accid].setIconPath(fldmeta_prop.gridconf.treeIconPath);
			fldmeta_prop.gridconf.treeImagePath && gdsav[accid].setImagePath(fldmeta_prop.gridconf.treeImagePath);
			fldmeta_prop.gridconf.extIconPath && (gdsav[accid].extIconPath = fldmeta_prop.gridconf.extIconPath);
			gdsav[accid].setInitWidths("170,60,120,30,*");
			gdsav[accid].setColumnIds("VARNAME,VARTYPE,VARDESC,IMG,MAPPING");
			gdsav[accid].setColTypes("tree,coro,ro,ro,ro");
			gdsav[accid].setColSorting("na,na,na,na,na");
			gdsav[accid].setColAlign("left,left,left,center,left");
			gdsav[accid].setEditable(false);
			gdsav[accid].enableDragAndDrop(true);
			gdsav[accid].setLang(flvar.lang);
			gdsav[accid].enableAlterCss("grid_even_row_white","grid_odd_row_white");
			gdsav[accid].init();
			
			/*var gdsdragging = {};	//保证每次拖动只mapping一次
			var gdsdragcount = 1;*/
			gdspv[accid].attachEvent("onDragIn", function(dId,tId,sObj,tObj){
				if (sObj==tObj) {
					return false;
				}
				if (dId!=null && tId!=null) {
					//must be same type
					if (sObj.getRowAttribute(dId, "isParam") && sObj.cells(dId, 1).getValue()==tObj.cells(tId, 1).getValue()) {
						sObj.cells(dId, 4).setValue(tObj.cells(tId, 0).getValue());
					}
				}
				return false;
			});
			/*gdspv[accid].attachEvent("onDragOut", function(dId,tId,sObj,tObj){
				console.debug("out="+gdsdragging[gdsdragcount]);
				return false;
			});*/
			gdsav[accid].attachEvent("onDragIn", function(dId,tId,sObj,tObj){
				if (sObj==tObj) {
					return false;
				}
				if (dId!=null && tId!=null) {
					/*console.debug("in="+gdsdragging[gdsdragcount]);
					if (gdsdragging[gdsdragcount]) {
						gdsdragging[gdsdragcount]=false;
						gdsdragcount++;
						tObj.cells(tId, 4).setValue(sObj.cells(dId, 0).getValue());
					} else {
						gdsdragging[gdsdragcount]=true;
					}*/
					//must be same type
					if (tObj.getRowAttribute(tId, "isParam") && tObj.cells(tId, 1).getValue()==sObj.cells(dId, 1).getValue()) {
						tObj.cells(tId, 4).setValue(sObj.cells(dId, 0).getValue());
					}
				}
				return false;//sObj._ui_seed != tObj._ui_seed;
			});
			/*gdsav[accid].attachEvent("onDrop", function(sId,tId,dId,sObj,tObj,sCol,tCol){
				
			});*/
			
			tbs[accid].attachEvent("onClick", function(tid) {
				if (tid=='btn_clear') {
					var srn = gdsav[accid].getSelectedRowId();
					if (srn==null) {
						msg(fmd_i18n_msg_sel);
					} else {
						gdsav[accid].cells(srn,4).setValue(null);
					}
				} else if (tid='btn_clearAll') {
					var rnn = gdsav[accid].getRowsNum();
					if (rnn) {
						for (var i=0; i<rnn; i++) {
							gdsav[accid].cellByIndex(i,4).setValue(null);
						}
					}
				}
			});
			
			//load existing process vars
			if (fl.curflow.bpmnConfig.processSettings.variables) {
				var count = 1;
				for (id in fl.curflow.bpmnConfig.processSettings.variables) {
					var rid = count++;
					gdspv[accid].addRow(rid, [id, fl.curflow.bpmnConfig.processSettings.variables[id].type,
					                    fl.curflow.bpmnConfig.processSettings.variables[id].allowin, 
					                    fl.curflow.bpmnConfig.processSettings.variables[id].allowout, 
					                    fl.curflow.bpmnConfig.processSettings.variables[id].desc]);
					gdspv[accid].grid_bindCombo(rid, 1, 
							fmd_i18n_prop_processvar_vals, 
							{"comboSize":10, "comboWidth":100}, 
							fl.curflow.bpmnConfig.processSettings.variables[id].type);
				}
			}
			//load existing activity vars
			loadActivityVars(0, activityVars[accid], accid);
			gdsav[accid].expandAll();
		}
		
		//init accordion cells 初始化手风琴控件，输入和输出各自占一个页签
		var acc1 = lo1.cells('a').attachAccordion();
		initAccCell(acc1, "input", fmd_i18n_title_dataMapping_input);
		initAccCell(acc1, "output", fmd_i18n_title_dataMapping_output);
		
		var str2 = [{ type:"block" , name:"form_block_1", offsetLeft:(dhx_skin=="dhx_web"?"335":"340"), offsetTop:"0", list:[
			   		{ type:"button" , name:"fb_ok", value:fmd_i18n_b_ok, inputTop:0  }]  }];
		var fm2 = lo1.cells('b').attachForm(str2);
		
		//绑定确定按钮事件
		fm2.attachEvent("onButtonClick", function(btid) {
			if (!fmdc.grid_prop.isEditor) {
				w1.close();
			} else if (btid=='fb_ok') {
				var dataMapping = {};
				function collectDatamapping(accid) {
					dataMapping[accid] = {};
					var mappedOut = {};	//在output中，记录哪些流程变量已经被mapping，不允许重复被mapping
					var rn = gdsav[accid].getRowsNum();
					if (rn) {
						for (var i=0; i<rn;i++) {
							var rid = gdsav[accid].getRowId(i);
							if (!gdsav[accid].getRowAttribute(rid, "isParam")) continue;
							var idvar = gdsav[accid].cells(rid,0).getValue();
							var idmapped = gdsav[accid].cells(rid,4).getValue();
							if ("output"==accid && mappedOut[idmapped]) {	//检验是否有重复mapping的流程变量
								msg(fmd_i18n_msg_dupPvDatamapping+": "+idmapped);
								return false;
							}
							if (idmapped!=null && idmapped!='' && idmapped!='&nbsp;') {
								dataMapping[accid][getVarPath(accid, rid, idvar)] = idmapped;
								mappedOut[idmapped] = true;
							}
						};
					}
					return true;
				}
				collectDatamapping("input");
				var rs1 = collectDatamapping("output");
				if (!rs1) return;
				
				fl.curflow.bpmnConfig[fl.curComp.id].dataMapping = dataMapping;
				fmdc.grid_prop.cells(rId, cId).setValue(dataMapping, true);
				//console.debug("data mapping="+JSON.stringify(fl.curflow.bpmnConfig[fl.curComp.id].dataMapping));
				w1.close();
			}
		});
	};
	
	//选择表单
	//来自表单变量
	fldmeta_prop.func.selectForm = function(rId, cId) {
		
		var w1 = fm_createCenterWindow('wid_selectForm', fmd_i18n_prop_selectformversion, 800, 600);
		var lo = w1.attachLayout("2E");
		lo.cells('a').hideHeader();
		lo.cells('b').hideHeader();
		lo.cells('b').setHeight(50);
		
		var str2 = [
			   		{ type:"block" , name:"form_block_1", offsetLeft:(dhx_skin=="dhx_web"?"333":"343"), offsetTop:"0", list:[
			   		{ type:"button" , name:"fb_ok", value:fmd_i18n_b_ok, inputTop:0  }
			   		]  }
			   	];
		var fm2 = lo.cells('b').attachForm(str2);
		var lo1 = lo.cells('a').attachLayout("2U");
		lo1.cells('a').setText(fmd_i18n_prop_form);
		lo1.cells('b').setText(fmd_i18n_prop_version);
		lo1.setAutoSize("a;b", "a;b");
		lo1.cells('a').setWidth(400);
		var fmg = {};
		fmg.rest_queryf = flvar.fmdCtx + '/rest/fmd/queryForm';
		fmg.rest_queryv = flvar.fmdCtx + '/rest/fmd/queryVersion';
		
		utp_initFormgrid();
		utp_initVersiongrid();
		
		fm2.attachEvent("onButtonClick", function(btid) {
			if (btid=='fb_ok') {
                if (!fmdc.grid_prop.isEditor) {
                    w1.close();return;
                }
				var rid = fmg.vergrid.getSelectedRowId();
				if (!rid) {
					msg(fmd_i18n_msg_plsselformver);
					return;
				}
				utp_returnBindingForm(rid);
			}
		});
		
		//查询
		utp_toPagef(1, 10);
		
		//grid for form layout
		function utp_initFormgrid() {
			fmg.stb = lo1.cells('a').attachStatusBar();
			fmg.stb.setText("<div id='id_paging_stb1'></div>");
			
			fmg.formgrid = lo1.cells('a').attachGrid();
			fmg.formgrid.setIconsPath(dhtmlx.image_path);
			fmg.formgrid.setHeader([fmd_i18n_l_no,"FORMID",fmd_i18n_prop_form_type,fmd_i18n_prop_form_name,fmd_i18n_prop_form_desc,fmd_i18n_prop_form_creator,fmd_i18n_prop_form_creatorname,"OP"],null,["text-align:center;","text-align:center;","text-align:center","text-align:center;","text-align:center;","text-align:center;","text-align:center;","text-align:center;"]);
			fmg.formgrid.attachHeader("#rspan,&nbsp;,#rspan,<input id='sr_formname' type='text' style='width:90%'/>,<input id='sr_formdesc' type='text' style='width:90%'/>,#rspan,#rspan,#rspan");
			fmg.formgrid.setInitWidths("40,200,80,150,250,60,80,100");
			fmg.formgrid.setColumnIds("ROW_NO,FORMID,FORMTYPE,FORMNAME,FORMDESC,CREATOR,CREATORNAME,OP");
			fmg.formgrid.setColTypes("ro,ro,pairro,ro,ro,ro,ro,ro");
			fmg.formgrid.setColSorting("na,str,str,str,str,str,str,str");
			fmg.formgrid.setColumnsVisibility("false,true,true,false,false,true,false,true");
			fmg.formgrid.setColAlign("center,left,center,left,left,left,center,left");
			fmg.formgrid.setEditable(false);
			fmg.formgrid.setLang(flvar.lang);
			//default ordering
			fmg.formgrid._grid_ordercolumns = [{"CREATETIME":"DESC"}];
			
			//paging
			fmg.formgrid.setPagingWTMode(true,true,true,[10,20,50,100]);
			fmg.formgrid.enablePaging(true,10,5,'id_paging_stb1');
			fmg.formgrid.setPagingSkin("toolbar", dhx_skin);
			
			fmg.formgrid.init();
			
			fmg.formgrid.attachEvent("onPageChanged", function(ind,fInd,lInd){
				utp_toPagef(fInd+1, lInd);
			});
			
			fmg.formgrid.attachEvent("onSelectStateChanged", function(grId){
				utp_toPagev(1, 10);
			});
			
			//header click event
			fmg.formgrid.attachEvent("onHeaderClick", grid_onHeaderClick);
			
			//bind searcher event
			//disable onclick order by function for this header
			var tdsr_formname = $("#sr_formname").parents('td:first');
			var tdsr_formdesc = $("#sr_formdesc").parents('td:first');
			var tdsr_formdescnext = $("#sr_formdesc").parents('td:first').next();
			tdsr_formname.bind('click',utp_stopEvent);
			tdsr_formdesc.bind('click',utp_stopEvent);
			tdsr_formdescnext.bind('click',utp_stopEvent);
			tdsr_formname.bind('mouseover',utp_stopEvent);
			tdsr_formdesc.bind('mouseover',utp_stopEvent);
			tdsr_formdescnext.bind('mouseover',utp_stopEvent);
			$("#sr_formname").bind('keypress', utp_enterQueryf);
			$("#sr_formdesc").bind('keypress', utp_enterQueryf);
		}

		//grid for version layout
		function utp_initVersiongrid() {
			fmg.vtb = lo1.cells('b').attachStatusBar();
			fmg.vtb.setText("<div id='id_paging_stb2'></div>");
			
			fmg.vergrid = lo1.cells('b').attachGrid();
			fmg.vergrid.setIconsPath(dhtmlx.image_path);
			fmg.vergrid.setHeader([fmd_i18n_l_no,"VERSIONID",fmd_i18n_prop_form_name,fmd_i18n_prop_form_desc,fmd_i18n_prop_form_updatetime,fmd_i18n_prop_form_changeuserid,fmd_i18n_prop_form_changeusername,fmd_i18n_prop_form_checkoutby,fmd_i18n_prop_form_checkoutbyname,fmd_i18n_prop_form_creator,fmd_i18n_prop_form_creatorname,fmd_i18n_prop_form_status,"OP"],
					null,
					["text-align:center;","text-align:left;","text-align:left","text-align:left","text-align:center;","text-align:center;","text-align:center;","text-align:center;","text-align:center;","text-align:center;","text-align:center;","text-align:center;","text-align:center;"]);
			fmg.vergrid.attachHeader("#rspan,#rspan,<input id='sr_versionname' type='text' style='width:90%'/>,<input id='sr_versiondesc' type='text' style='width:90%'/>,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan");
			fmg.vergrid.setInitWidths("40,100,150,250,120,80,80,80,80,80,80,80,100");
			fmg.vergrid.setColumnIds("ROW_NO,VERSIONID,VERSIONNAME,VERSIONDESC,UPDATETIME,CHANGEUSERID,CHANGEUSERNAME,CHECKOUTBY,CHECKOUTBYNAME,CREATOR,CREATORNAME,STATUS,OP");
			fmg.vergrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,pairro,ro");
			fmg.vergrid.setColSorting("na,str,str,str,str,str,str,str,str,str,str,str,str");
			fmg.vergrid.setColumnsVisibility("false,true,false,false,false,true,false,true,false,true,false,true,true");
			fmg.vergrid.setColAlign("center,left,left,left,center,center,center,center,center,center,center,center,center");
			fmg.vergrid.setEditable(false);
			fmg.vergrid.setLang(flvar.lang);
			fmg.vergrid.init();
			
			//default order by
			//fmg.vergrid._grid_ordercolumns = [{"CREATETIME":"DESC"}];
			
			//paging
			fmg.vergrid.setPagingWTMode(true,true,true,[10,20,50,100]);
			fmg.vergrid.enablePaging(true,10,5,'id_paging_stb2');
			fmg.vergrid.setPagingSkin("toolbar", dhx_skin);
			
			fmg.vergrid.attachEvent("onPageChanged", function(ind,fInd,lInd){
				utp_toPagev(fInd+1, lInd);
			});
			
			//header click event
			fmg.vergrid.attachEvent("onHeaderClick", grid_onHeaderClick);
			
			fmg.vergrid.attachEvent("onRowDblClicked", function(grId, gcInd){
				utp_returnBindingForm(grId);
			});
			
			//bind searcher event
			//disable onclick order by function for this header
			var trsr_versionname = $("#sr_versionname").parents('tr:first');
			trsr_versionname.find('td').bind('click',utp_stopEvent);
			trsr_versionname.find('td').bind('mouseover',utp_stopEvent);
			$("#sr_versionname").bind('keypress', utp_enterQueryv);
			$("#sr_versiondesc").bind('keypress', utp_enterQueryv);
		}
		
		//query form
		function utp_toPagef(fromRow, toRow){
			lo1.cells('a').progressOn();
			var p = {"form":{"formtype":"PROCESS"}, "fromRow":fromRow, "toRow":toRow, "timezoneOffset":new Date().getTimezoneOffset(),
					"ordercolumns":JSON.stringify(fmg.formgrid._grid_ordercolumns)};
			if (fmg.fquery_formname) {
				p.form.formname = fmg.fquery_formname;
			}
			if (fmg.fquery_formdesc) {
				p.form.formdesc = fmg.fquery_formdesc;
			}
			p.form = JSON.stringify(p.form);
			var ret = doPostSyncJson(fmg.rest_queryf, p);
			if (!ret) {
				lo1.cells('a').progressOff();
				msgErr(fmd_i18n_msg_readfail);
				return;
			}
			fmg.formgrid.clearAllInPaging();
			fmg.formgrid.parse(ret, "json");
			fmg.vergrid.clearAllInPaging();
			lo1.cells('a').progressOff();
		}

		//call query form
		function utp_enterQueryf(e) {
			if (e.keyCode==13) {
				fmg.fquery_formname = $.trim($("#sr_formname").val());
				fmg.fquery_formdesc = $.trim($("#sr_formdesc").val());
				utp_toPagef(1, 10);
			}
		}

		//query version
		function utp_toPagev(fromRow, toRow){
			lo1.cells('b').progressOn();
			var p = {"args":{"excludeCurrent":"1"}, "fromRow":fromRow, "toRow":toRow, "timezoneOffset":new Date().getTimezoneOffset(),
					"ordercolumns":JSON.stringify(fmg.vergrid._grid_ordercolumns)};
			p.args.formid = fmg.formgrid.cells(fmg.formgrid.getSelectedRowId(), fmg.formgrid.getColIndexById("FORMID")).getValue();
			if (fmg.vquery_versionname) {
				p.args.versionname = fmg.vquery_versionname;
			}
			if (fmg.vquery_versiondesc) {
				p.args.versiondesc = fmg.vquery_versiondesc;
			}
			p.args = JSON.stringify(p.args);
			var ret = doPostSyncJson(fmg.rest_queryv, p);
			if (!ret) {
				lo1.cells('b').progressOff();
				msgErr(fmd_i18n_msg_readfail);
				return;
			}
			fmg.vergrid.clearAllInPaging();
			fmg.vergrid.parse(ret, "json");
			//hide current version display
			var sr = fmg.vergrid.findCell("0",fmg.vergrid.getColIndexById("VERSIONID"),true);
			if (sr && sr.length && sr[0].length) {
				fmg.vergrid.setRowHidden(sr[0][0]);
			}
			lo1.cells('b').progressOff();
		}

		//call query version
		function utp_enterQueryv(e) {
			if (e.keyCode==13) {
				fmg.vquery_versionname = $.trim($("#sr_versionname").val());
				fmg.vquery_versiondesc = $.trim($("#sr_versiondesc").val());
				utp_toPagev(1, 10);
			}
		}

		//stop event propagation
		function utp_stopEvent(e){
			if (e && e.stopPropagation!=undefined) {
				e.stopPropagation();
			} else if (window.event){
				window.event.cancelBubble = true;
			}
			return false;
		}
		
		//返回
		function utp_returnBindingForm(rid) {
            if (!fmdc.grid_prop.isEditor) {
                w1.close();return;
            }
			var newval = {};
			var frid = fmg.formgrid.getSelectedRowId();
			newval.formid = fmg.formgrid.cells(frid, fmg.formgrid.getColIndexById("FORMID")).getValue();
			newval.formname = fmg.formgrid.cells(frid, fmg.formgrid.getColIndexById("FORMNAME")).getValue();
			newval.versionid = fmg.vergrid.cells(rid, fmg.vergrid.getColIndexById("VERSIONID")).getValue();
			newval.versionname= fmg.vergrid.cells(rid, fmg.vergrid.getColIndexById("VERSIONNAME")).getValue();
			newval.displayValue = newval.formname + " : " + newval.versionname;
			fmdc.grid_prop.cells(rId, cId).setValue(newval, true);	//第二个参数必须为true，触发事件
			w1.close();
		}
		
	}
	
	/**
	 * common properties that can be reused
	 */
	
	//组件名称，当文本标签在控件内部时使用
	fldmeta_prop.common.predefined["i18nname-zh-inner"] = {
			"name" : fmd_i18n_prop_i18nnamezh,
			"cellType" : "ro",
			"tooltip" : fmd_i18n_tooltip_i18nnamezh,
	    	"img" : "name_zh.png",
	    	"value" : fldmeta_prop.func.getCurCompInnerName,
	    	"afterProperty" : "i18ntype"
		};
	//组件名称，当文本标签在控件外部时使用
	fldmeta_prop.common.predefined["i18nname-zh-outer"] = {
			"name" : fmd_i18n_prop_i18nnamezh,
			"cellType" : "ro",
			"tooltip" : fmd_i18n_tooltip_i18nnamezh,
	    	"img" : "name_zh.png",
	    	"value" : fldmeta_prop.func.getCurCompOuterName,
	    	"afterProperty" : "i18ntype"
		};
	//组件描述
	fldmeta_prop.common.predefined["i18ntypeDesc"] = {
	    	"name" : fmd_i18n_prop_selectiontype,
	    	"img" : "selection.png",
	    	"tooltip" : fmd_i18n_tooltip_i18ntip,
	    	"cellType" : "ro",
	    	"value" : fldmeta_prop.func.getCurCompTypeName,
	    	"displayOnly" : true
	    };
	//组件类型的真实值，隐藏属性
	fldmeta_prop.common.predefined["i18ntype"] = {
	    	"name" : fmd_i18n_prop_selectiontype,
	    	"img" : "selection.png",
	    	"cellType" : "ro",
	    	"value" : function(){return fl.curComp.type;},
	    	"hide" : true
	    };
	//到期时间
	fldmeta_prop.common.predefined["duration"] = {
	    	"name" : function(elemid) {
	    		var unit='';
	    		if ('day'==fl.curflow.otherConfig.timelineunit) {
	    			unit = fmd_i18n_unitday;
	    		} else if ('hour'==fl.curflow.otherConfig.timelineunit) {
	    			unit = fmd_i18n_unithour;
	    		}
	    		return fmd_i18n_prop_duration + "("+unit+")";
	    	},
	    	"img" : "duration.png",
	    	"tooltip" : fmd_i18n_tooltip_duration,
	    	"cellType" : {
	    		"type" : "jquispinner",
	    		"config" : {
	    			"spin": function( event, ui ) {
						if ( ui.value < 1 ) {
							$( this ).spinner( "value", 1 );
							return false;
						}
					}
	    		}
	    	},
	    	"value" : {"default":5},
	    	"validator" : "ValidPositiveInteger"
	    };
	
	//自动提醒
	fldmeta_prop.common.predefined["remind"] = {
	    	"name" : fmd_i18n_prop_remind,
	    	"img" : "ring2.png",
	    	"tooltip" : fmd_i18n_tooltip_remind,
	    	"cellType" : "ch",
	    	"value" : {"default":0},
	    	"conditional-sub" : {
	    		"1" : {
	    			"remindmethods" : {//提醒方式
	    		    	"name" : fmd_i18n_prop_remindmethods,
	    		    	"img" : "ring2.png",
	    		    	"cellType" : {
							"type" : "colist",
							"config": {
		    		    		"list" : fmd_i18n_prop_remindmethods_vals
		    		    	}
					    },
	    		    	"value" : {"default":"email"},
	    		    	"validatorFunc" : function(elemid, value, prefix) {
	    		    		if (fl.curflow.bpmnConfig[elemid].remind && !value) {
	    		    			//return {"type":"error", "msg":fmd_i18n_msg_remindNoMethod};
	    		    			fl_pushValidationErr(elemid, "remindmethods", "error", prefix + fmd_i18n_msg_remindNoMethod);
	    		    		}
	    		    		return null;
	    		    	}
	    		    },
	    		    "remindunit" : {//提前提醒的时间单位
	    		    	"name" : fmd_i18n_prop_remindunit,
	    		    	"img" : "ring2.png",
	    		    	"cellType" : {
							"type" : "coro",
							"options": fmd_i18n_prop_remindunit_vals
					    },
	    		    	"value" : {"default":"day"}
	    		    },
	    		    "remindtime" : {//提前提醒时间
	    		    	"name" : fmd_i18n_prop_remindtime,
	    		    	"img" : "ring2.png",
	    		    	"cellType" : {
	    		    		"type" : "jquispinner",
	    		    		"config" : {
	    		    			"spin": function( event, ui ) {
		    						if ( ui.value < 0 ) {
		    							$( this ).spinner( "value", 0 );
		    							return false;
		    						}
		    					}
	    		    		}
	    		    	},
	    		    	"value" : {"default":1},
	    		    	"validator" : "ValidPositiveInteger"
	    		    }
	    		}
	    	}
	    };
	
	//手动提醒
	fldmeta_prop.common.predefined["manualRemind"] = {
			"name" : fmd_i18n_prop_manualRemind,
	    	"img" : "ring1.png",
	    	"tooltip" : fmd_i18n_prop_manualRemind,
	    	"cellType" : "ch",
	    	"value" : {"default":0},
	    	"conditional-sub" : {
	    		"1" : {
	    			"manualRemindmethods" : {//手动提醒方式
	    		    	"name" : fmd_i18n_prop_remindmethods,
	    		    	"img" : "ring1.png",
	    		    	"cellType" : {
							"type" : "colist",
							"config": {
		    		    		"list" : fmd_i18n_prop_remindmethods_vals
		    		    	}
					    },
	    		    	"value" : {"default":"email"},
	    		    	"validatorFunc" : function(elemid, value, prefix) {
	    		    		if (fl.curflow.bpmnConfig[elemid].manualRemind && !value) {
	    		    			//return {"type":"error", "msg":fmd_i18n_msg_manualRemindNoMethod};
	    		    			fl_pushValidationErr(elemid, "manualRemindmethods", "error", prefix + fmd_i18n_msg_manualRemindNoMethod);
	    		    		}
	    		    		return null;
	    		    	}
	    		    }
	    		}
	    	}
	    };
	
	//auto complete on expiration
	fldmeta_prop.common.predefined["autoCompleteOnExpiration"] = {
	    	"name" : fmd_i18n_prop_autoCompleteOnExpiration,
	    	"img" : "autoCompleteOnExpiration.png",
	    	"tooltip" : fmd_i18n_tooltip_autoCompleteOnExpiration,
	    	"cellType" : "ch",
	    	"value" : {"default":0}
	    };
	
	//set route 路由设置
	fldmeta_prop.common.predefined["route"] = {
	    	"name" : fmd_i18n_prop_route,
	    	"img" : "route.png",
	    	"tooltip" : fmd_i18n_tooltip_route,
	    	"cellType" : {
	    		"type" : "btnex",
	    		"config" : {
					"onclick" : fldmeta_prop.func.setRoute
				}
	    	},
	    	"value" : {"default" : null},
	    	"validatorFunc" : function(elemid, val, prefix) {
	    		var seqflows = fldmeta_prop.func.getOutgoingTransitions(elemid);
	    		/*bi.saveDiagram(function(err, xml){
					var params = {
							"xmlStr" : xml,
							"xpath" : "//bpmn2:sequenceFlow[@sourceRef='"+elemid+"']|//bpmn2:messageFlow[@sourceRef='"+elemid+"']",
							"attrlist" : JSON.stringify(["id","name","targetRef"])
						};
					seqflows = doPostSyncJson(flvar.bpmeRest + "/"+flvar.flowRes+"/getElementAttrs", params);
				});*/
	    		if (seqflows && seqflows.length>1) {
	    			if (!val || MyUtilJs.isEmpty(val)) {
	    				//return {"type":"warning", "msg":fmd_i18n_msg_noRouteSetting};
	    				fl_pushValidationErr(elemid, "route", "warning", prefix + fmd_i18n_msg_noRouteSetting);
	    			}
	    		}
	    		return null;
	    	}
	    };
	
	
	/**
	 * styles 风格样式定义 =====================================
	 */
	
	//displayStyle_bgColor 当前主题
	fldmeta_prop.common.predefined["curTheme"] = {
			"name" : fmd_i18n_prop_curTheme,
	    	"cellType" : "ro",
	    	"img" : "css.png",
	    	"displayOnly" : true,
	    	"value" : function() {
	    		return fmdi18n.themes[fl.curflow.otherConfig.theme];
	    	}
		};
	
	//displayStyle_bgColor 背景颜色
	fldmeta_prop.common.predefined["displayStyle_bgColor"] = {
			"name" : fmd_i18n_prop_bgcolor,
	    	"cellType" : "cp",
	    	"img" : "bgcolor.png",
	    	"value" : {"default":"#ffffff"}
		};
	
	//displayStyle_bgOpacity 背景透明度
	fldmeta_prop.common.predefined["displayStyle_bgOpacity"] = {
			"name" : fmd_i18n_prop_bgopacity,
			"cellType" : {
	    		"type" : "coro",
	    		"options" : fmd_i18n_prop_bgOpacity_vals
	    	},
	    	"img" : "bgopacity.png",
	    	"value" : {"default":1}
		};
	
	//displayStyle_BorderStroke 边框宽度
	fldmeta_prop.common.predefined["displayStyle_BorderStrokeWidth"] = {
			"name" : fmd_i18n_prop_borderStrokeWidth,
			"cellType" : {
	    		"type" : "coro",
	    		"options" : fmd_i18n_prop_borderStrokeWidth_vals
	    	},
	    	"img" : "borderStrokeWidth.png",
	    	"value" : {"default":1}
		};
	
	//displayStyle_BorderColor 边框颜色
	fldmeta_prop.common.predefined["displayStyle_BorderColor"] = {
			"name" : fmd_i18n_prop_borderColor,
	    	"cellType" : "cp",
	    	"img" : "borderColor.png",
	    	"value" : {"default":"#666666"}
		};
	
	//displayStyle_BorderEffect 边框特效
	fldmeta_prop.common.predefined["displayStyle_BorderEffect"] = {
			"name" : fmd_i18n_prop_borderEffect,
	    	"cellType" : {
	    		"type" : "coro",
	    		"options" : fmd_i18n_prop_borderEffect_vals
	    	},
	    	"img" : "borderEffect.png",
	    	"value" : {"default":"none"}
		};
	
	//displayStyle_ActivityIconColor 图标颜色
	fldmeta_prop.common.predefined["displayStyle_ActivityIconColor"] = {
			"name" : fmd_i18n_prop_ActivityIconColor,
	    	"cellType" : "cp",
	    	"img" : "activityIconColor.png",
	    	"value" : {"default":"#000000"}
		};
	
	//displayStyle_fontColor 字体颜色
	fldmeta_prop.common.predefined["displayStyle_fontColor"] = {
			"name" : fmd_i18n_prop_FontColor,
	    	"cellType" : "cp",
	    	"img" : "fontColor.png",
	    	"value" : {"default":"#000000"}
		};
	
	//displayStyle_connPathColor 连接线颜色
	fldmeta_prop.common.predefined["displayStyle_connPathColor"] = {
			"name" : fmd_i18n_prop_connPathColor,
	    	"cellType" : "cp",
	    	"img" : "connPathColor.png",
	    	"value" : {"default":"#000000"}
		};
	
	//displayStyle_showActivityIcon 是否显示图标
	fldmeta_prop.common.predefined["displayStyle_showActivityIcon"] = {
			"name" : fmd_i18n_prop_showActivityIcon,
	    	"cellType" : "ch",
	    	"img" : "activityIconColor.png",
	    	"value" : {"default":"1"},
	    	"conditional-sub" : {
	    		"1" : {
	    			"displayStyle_ActivityIconColor" : fldmeta_prop.common.predefined["displayStyle_ActivityIconColor"]
	    		}
	    	}
		};

	/**
	 * common for all components 所有组件通用属性
	 */
	fldmeta_prop.common.all = {
			"properties" : {
				"id" : {//id
			    	"name" : "id",
			    	"img" : "id.png",
			    	"tooltip" : fmd_i18n_tooltip_id,
			    	"cellType" : "ro",
			    	"value" : {"fromattr" : "id"},
			    	"displayOnly" : true
			    },
			    "i18ntypeDesc" : fldmeta_prop.common.predefined["i18ntypeDesc"],//类型名称
			    "i18ntype" : fldmeta_prop.common.predefined["i18ntype"],//类型真实值
			    "description" : {//描述
			    	"name" : fmd_i18n_prop_description,
			    	"img" : "property.png",
			    	"cellType" : "txt",
			    	"value" : {"default" : null},
			    	"validatorFunc" : function(elemid, value, prefix) {
    		    		if (value && value.length>40) {
    		    			//return {"type":"error", "msg":fmd_i18n_msg_remindNoMethod};
    		    			fl_pushValidationErr(elemid, "description", "warning", prefix + fmd_i18n_msg_toolong + "40");
    		    		}
    		    		return null;
    		    	}
			    }/*,
			    "bgcolor" : {
			    	"name" : "背景颜色",
			    	"img" : "css.png",
			    	"tooltip" : "选择背景颜色",
			    	"cellType" : "cp",
			    	"value" : {"default" : ""}
		    	},
			    "style" : {
			    	"name" : fmd_i18n_prop_style,
			    	"img" : "css.png",
			    	"tooltip" : fmd_i18n_tooltip_style,
			    	"cellType" : "ace_text"
			    }*/
			}
		};

	/**
	 * common properties settings for all activity components
	 * 任务环节通用属性
	 */
	fldmeta_prop.common.activity = {
			"properties" : {
				"i18nname-zh" : function() {//名称
					var p = MyUtilJs.copyObj(fldmeta_prop.common.predefined["i18nname-zh-inner"]);
					p.validator = {level:"warning", validator:"NotEmpty"};
					return p;
				},
				"route" : fldmeta_prop.common.predefined["route"]//路由配置
			}
		};
	
	/**
	 * common properties settings for all layout components
	 * 布局控件的通用属性
	 */
	fldmeta_prop.common.layout = {
		"properties" : {
			"i18nname-zh" : fldmeta_prop.common.predefined["i18nname-zh-inner"]//名称
		}
	};
	
	/**
	 * common properties settings for all event components
	 * 事件组件的通用属性
	 */
	fldmeta_prop.common.event = {
		"properties" : {
			"i18nname-zh" : fldmeta_prop.common.predefined["i18nname-zh-outer"]//名称
		}
	};
	
	/**
	 * common properties settings for all gateway components
	 * 网关的通用属性
	 */
	fldmeta_prop.common.gateway = {
		"properties" : {
			"i18nname-zh" : fldmeta_prop.common.predefined["i18nname-zh-outer"]//名称
		}
	};
	
	/**
	 * common properties settings for all connection components
	 * 链接线的通用属性
	 */
	fldmeta_prop.common.connection = {
		"properties" : {
			"i18nname-zh" : fldmeta_prop.common.predefined["i18nname-zh-outer"]//名称
		}
	};

}




